<template>
    <el-table :data="filterTableData" style="width: 100%" size="defalut">
      <el-table-column label="序号" prop="disid" />
      <el-table-column label="病人姓名" prop="patientname" />
      <el-table-column label="所开药方" prop="medicines" />
      <el-table-column label="金额" prop="dismoney" />
      <el-table-column label="治疗日期" prop="distime" />
      <!-- <el-table-column prop="founder" label="创建人" /> -->
      <el-table-column align="right">
        <template #header>
          <el-input v-model="search" size="default" placeholder="Type to search" />
        </template>
        <!-- <template #default="scope">
          <el-button size="default" type="primary" @click="handleDelete(scope.$index)">修改</el-button>
        </template> -->
      </el-table-column>
    </el-table>
  </template>
  
  <script lang="ts" setup>
  import { computed, ref } from 'vue'
  import service from "../request/index";
  import user from "@/store";
//   interface form {
//   disid:string
//   patientname:string 
//   medicines: string
//   dismoney:string
//   distime:Date
// }
  // var tableData = ref([]);
  const select = async () => {
  console.log("获取数据");
  try {
    const response = await service.post("/Diagnosis/doctorDiagnosis",
      {
        doctorName : user.state.user.loginUser.userName,
      }
    );
    form.value = response.data;
    console.log(form.value);
  } catch (error) {
    console.error("获取预约信息失败：", error);
  }
};
select();
var form = ref([])

const search = ref('')
const filterTableData = computed(() =>{
  if (!form.value) {
    return [];
  }
    return form.value.filter(
      (data) =>
        !search.value ||
        data.patientname.toLowerCase().includes(search.value.toLowerCase())
    )
}
  )


  </script>
  